<script lang="ts" setup>
import { h, useSlots } from "vue";
import type { VNode } from "vue";

// 获取默认插槽
const slots = useSlots();
const defaults = slots.default?.();

function render() {
  // 在每一个导航的后面加分隔符, 除了最后一个
  let result = defaults?.reduce(
    (result: VNode[], item, index, array) =>
      result.concat(
        index < array.length - 1
          ? [
              item,
              h("i", {
                class: "iconfont icon-angle-right",
              }),
            ]
          : [item]
      ),
    []
  );
  return h("div", { class: "xtx-bread" }, result);
}
</script>
<template>
  <render />
</template>
<style scoped lang="less">
.xtx-bread {
  display: flex;
  padding: 25px 10px;
  &-item {
    a {
      color: #666;
      transition: all 0.4s;
      &:hover {
        color: @xtxColor;
      }
    }
  }
  i {
    font-size: 12px;
    margin-left: 5px;
    margin-right: 5px;
    line-height: 22px;
  }
}
</style>
